<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="wf" uri="/augurit-wf"%>

<%@ include file="/common/meta.jsp"%>
<%@ include file="/common/meta_ext.jsp"%>
<%@ include file="/wf/public/meta_wf.jsp"%><%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>预览处置证</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style type="text/css">
			.titleCss{
				font-size:330%;
				text-align:center;
				font-weight: bold;
			}
			.justifyCss{
				width:30%;
				text-align:justify;
				text-justify:distribute-all-lines;
				text-align-last:justify;
			}
			.tdCss{
				font-size:200%;
				font-weight: bold;
			}
			.inputNoborder {
			    FONT-SIZE: 30px;
			    FONT-FAMILY: 宋体;
			    BORDER-RIGHT: #FFFFFF 1px solid;
			    BORDER-TOP: #FFFFFF 1px solid;
			    BORDER-LEFT: #FFFFFF 1px solid;
			    BORDER-BOTTOM: #FFFFFF 1px solid;
			}
			.bb{
				margin-left:80px;
			}
		</style>
		  <script src="${ctx}/resources/js/ext/adapter/ext/ext-base.js" type="text/javascript"></script>
         <script src="${ctx}/resources/js/ext/ext-all.js" type="text/javascript"></script>
         <script src="${ctx}/gzcgwsp/resources/js/YwUtil.js" type="text/javascript"></script>
	</head>
	<script type="text/javascript">  
	var contextpath="<%=basePath%>";
		var fileSavePath=getPathBySystem(); 
		//根据操作系统用不同的路径
		function getPathBySystem(){
		     var path="";
		     var ua = navigator.userAgent.toLowerCase();
		     if(ua.indexOf("linux")>=0){
		        path="/usr/local/temp";
		     }else{
		        path="C:\\TEMP\\";
		     }
		    return path;
		}
		
		//盖章按钮
        function gzJyxkzs(){
           var chinesename = document.getElementById("sqdw").value+
           					document.getElementById("acceptNo").value+"许可证.xls";
           var filepath=contextpath+"/"+document.getElementById("templateFilePath").value;
  		   var filename = filepath.substring(filepath.lastIndexOf("/")+1);
  		   TransUpload(filename,chinesename,filepath)
        }
    
		function TransUpload(result,chinesename,filepath){
			var newpath=MakeWord(result,chinesename,filepath);// 打开word ，把它保存在D盘，相当于下载
			var DocName, CebName, LogName, IniName;
			var DocNameLen;
			var DocNameWONLen;
			var cebtail;
		//	DocName = NewDocForm.OriginalFile.value;
		 	DocName =newpath;
			DocNameLen = DocName.length;
			DocNameWONLen = DocName.lastIndexOf(".") - 1;
			if (DocNameWONLen == -1){
				DocNameWONLen = DocNameLen;
			}else{
				cebtail = DocName.substring(DocNameWONLen+2, DocNameLen);
			}
			if (cebtail.toLowerCase() == "ceb"){
				CebName = DocName;
			}else{
				CebName = DocName.substring(0, DocNameWONLen+1) + ".ceb";
			}
			
			LogName = DocName.substring(0, DocNameWONLen+1) + ".log";
			IniName = DocName.substring(0, DocNameWONLen+1) + ".ini";
			if (DocName != CebName){
				if (!(transMaker(DocName, CebName, LogName, IniName))){// 格式转换
					alert("格式转换失败，请重试！");
					return false;
				}		
			}
			else{
				alert("当前格式为ceb格式！");
			}
			var f=newpath.substring(0,newpath.lastIndexOf("."))+".ceb";
			Stamp_onclick(f);//盖章
			document.getElementById("t1").value=f;
			callSet(chinesename);//上传
			return true;

		}
		//格式转换
		function transMaker(DocName, CebName, LogName, IniName){
			var DTracker;
			DTracker = new ActiveXObject("MakerCom.MakerExt.1");
			var nRet;
			var Error;
			//alert("正转换文件，请稍候......");		
			nRet = DTracker.BeginMaker("");
			if (nRet != 0){
				alert(DTracker.GetErrorMessage(nRet));		
				delete DTracker;
				return false;
			}		
		    //alert("开始文档格式转换......请稍后!");		
			nRet = DTracker.SingleFileConvert(DocName, CebName, "标准模板", LogName, IniName);	
			if (nRet != 0){
				alert("MakerOcx transfer error!");
				nRet = DTracker.EndMaker();		
				delete DTracker;
				return false;
			}
			nRet = DTracker.EndMaker();
			if (nRet != 0){
				alert("MakerOcx End error!");		
				delete DTracker;
				return false;
			}	
			alert("格式转换完成！");	
			delete DTracker;
			return true;
		}
		//文件保存到本地
		 function MakeWord(filename,chinesename,filepath){
	        var WordApp=new ActiveXObject("Excel.Application");
	        var newpath=fileSavePath+chinesename;
	        var url=filepath;
        	WordApp.Visible = false;
	        var Doc=WordApp.Workbooks.open(url);
	        Doc.saveAs(newpath);
	        Doc.Close();
	        WordApp.Application.Quit();
	        return newpath;
 		}
        </script>
        <script language="vbs">
Function Stamp_onclick(strCEBFileName)    	
	Dim strErrMessage, lRet, objStampClientTool,g_AffixRegisterURL,g_SendPrintURL,UnitName
	g_AffixRegisterURL="http://172.16.253.169/StampServer/interfaces/background/AffixRegister.aspx"
	g_SendPrintURL="http://172.16.253.169/StampServer/extend/interfaces/SendPrint.aspx"
	UnitName=""

	lRet = ""
	strErrMessage = ""
	strCEBFileName = trim(strCEBFileName)

	if  0 = len(trim(strCEBFileName)) then
		Call Alert("请选择CEB文件！", vbExclamation, "请选择CEB文件！")
		Exit Function
	else
		if UCase(Right(Trim(strCEBFileName), 3)) <> "CEB" then
			Call Alert("只能选择CEB格式的文件！", vbExclamation, "只能选择CEB格式的文件！")
			CEBFileName.value = ""
			Exit Function
		end if                  	 	  
	end if

	set objStampClientTool  = CreateObject("StampClientTool.StampTool")

	' 本地可视化盖章	
	lRet = objStampClientTool.LocalSealStamp(strCEBFileName, UnitName, g_AffixRegisterURL, g_SendPrintURL)
	
	if lRet <> 0 then
		strErrMessage = objStampClientTool.GetErrorMessage()
        alert "盖章失败原因:" & strErrMessage
	end if

	Set objStampClientTool = Nothing	
End Function

Sub PreviewCEB(xuwei)
	Dim lRet
	lRet = DCreateGBForm1.ViewLocalCEB(xuwei)
End Sub

Sub PreviewNetCEB(xuwei)
	Dim lRet
	lRet = DCreateGBForm1.ViewNetCEB(xuwei)
End Sub

</script>
	<body>
		<form action="" method="POST" target="autoPrintIFrame">
		<input type="hidden" name="id" id="czzId" value="${id}"/>
		<input type="hidden" name="activName" id="activName" value="${activName}"/>		
	    <input type="hidden" name="taskInstDbid" id="taskInstDbid" value="${taskInstDbid}"/>
		<input type="hidden" name="templateCode" id="templateCode" value="${templateCode}"/>
		<input type="hidden" name="sqdw" id="sqdw" value="${sqdw}">
		<input type="hidden" id="acceptNo" value="${acceptNo}"/>
		<input type="hidden" name="templateFilePath" id="templateFilePath" value="${templateFilePath}">
		<table border="0" width="100%" style="margin-top:10px">
			<tr>
				<td width="3%">&nbsp;&nbsp;&nbsp;&nbsp;</td>
				<td width="45%">
					<table width="100%" border="0" align="center">
						<tr>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td class="titleCss"  align="center">广&nbsp;州&nbsp;市<br>建筑废弃物处置证（排放）</td>
						</tr>
						<tr>
							<td align="center" style="font-size:120%;letter-spacing:4px;">
								<br/>
								NO：&nbsp;（<input name="zsno" id="zsno" value="${zsno }" class="inputNoborder" style="FONT-SIZE: 20px;width:100px;"/>）&nbsp;
								排字第&nbsp;<input name="zsbh" id="zsbh" value="${zsbh }" class="inputNoborder" style="FONT-SIZE: 20px;width:100px;"/>号
							</td>
						</tr>
						<tr>
							<td class="titleCss"  align="center">
								<br/><br/>
							</td>
						</tr>
						<tr>
							<td style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">
								&nbsp;&nbsp;&nbsp;&nbsp;根据《广州市建筑废弃物管理条例》规定，经审核，本工程符合建筑废弃物排放处置的许可条件，准予发证。
							</td>
						</tr>
						<tr>
							<td class="titleCss"  align="center">
								<br/><br/><br/><br/>
							</td>
						</tr>
						<tr>
							<td align="right" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">
								发证单位：<input name="fzdw" id="fzdw" value="${fzdw }" class="inputNoborder" style="FONT-SIZE: 20px;width:250px;"/>
							</td>
						</tr>
						<tr>
							<td align="right" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">
								<input id="fzrq" name="fzrq" value="<s:date name='fzrq' format="yyyy年MM月dd日"/>" type="text" style="width:180" onclick="WdatePicker({skin:'ext', dateFmt:'yyyy年MM月dd日'});" class="textdocWdate"/>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							</td>
						</tr>
					</table>
				</td>
				<td width="4%">&nbsp;&nbsp;&nbsp;&nbsp;</td>
				<td width="45%" valign="top">
					<table width="100%" border="1" align="center" bordercolor="black">
						<tr><td colspan="4"></td></tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">建设单位</td>
							<td width="80%" colspan="3">${sqdw }</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">联系人</td>
							<td width="20%">${jsdwLxr}</td>
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">联系电话</td>
							<td width="20%">${jsdwLxrLxdh}</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">施工单位</td>
							<td width="80%" colspan="3">${sgdwGz}</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">联系人</td>
							<td width="20%">${sgdwLxr}</td>
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">联系电话</td>
							<td width="20%">${sgdwLxrLxdh}</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">运输单位</td>
							<td width="80%" colspan="3">${ysgs }</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">联系人</td>
							<td width="20%">${ysgsLxr}</td>
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">联系电话</td>
							<td width="20%">${ysgsLxrLxdh}</td>
						</tr>

						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">工程名称</td>
							<td width="80%" colspan="3">${gcmc }</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">工程地址</td>
							<td width="80%" colspan="3">${gcdz}</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">许可范围</td>
							<td width="80%" colspan="3">排放建筑废弃物</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">排放处置量</td>
							<td width="80%" colspan="3">
							<s:if test="pfczl==null">
							 <input id="pfczl" name="pfczl" value="${jsztf }" style="width:100%"/>
							</s:if>
							<s:else>
							  <input id="pfczl" name="pfczl" value="${pfczl }" style="width:100%"/>
							</s:else>
							
							
							</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">有效期限</td>
							<td width="80%" colspan="3">
							<input type="text" name="zsksrq" id="zsksrq" style="width:150px" value="<s:date name='zsksrq' format="yyyy年MM月dd日"/>" onclick="WdatePicker({skin:'ext', dateFmt:'yyyy年MM月dd日'});" type="text" class="textdocWdate" readonly/>
							
							&nbsp;&nbsp;
							
							至&nbsp;&nbsp;
							
							<input type="text" name="zsjsrq" id="zsjsrq"  style="width:150px" value="<s:date name='zsjsrq' format="yyyy年MM月dd日"/>" onclick="WdatePicker({skin:'ext', dateFmt:'yyyy年MM月dd日'});" type="text" class="textdocWdate" readonly/>
							
							</td>
						</tr>
						<tr height="30px">
							<td width="20%" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">备注</td>
							<td width="80%" colspan="3"><textarea rows="8" style="width:100%" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;" readonly>${bz}</textarea></td>
						</tr>
					</table>
				</td>
				<td width="3%">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="5" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">
					<br><br>
				</td>
			</tr>
			<tr>
				<td colspan="5" align="center" style="font-size:120%;letter-spacing:4px;line-height:30px;FONT-FAMILY: 宋体;">
					<input type="button" onclick="gzJyxkzs();"  id="printzs" value="盖章" style="width:100px;"/>
					<input type="button" onclick="viewJyxkzs();"  id="printzs" value="查看盖章" style="width:100px;"/>
					<input type="button" value="关闭窗口" onclick="window.close();" style="width:100px;"/>
				</td>
			</tr>
		</table>
		<br><br>
		
		
		
		</form>
		<div id="autoPrintDiv" style="display:none;"><iframe height='1000' width='700' name='autoPrintIFrame'/></div>
	</body>
</html>